import React from 'react';
import { Alert } from 'react-native';
import { Scene, Actions, ActionConst } from 'react-native-router-flux';
// import Form from '../../../components/Form';
// import NavBarIconBtn from '../../../components/NavBarIconBtn';
import user from '../../../common/models/user';
import navBarStyle from '../../../components/navBarStyle';
import MyForm from './Form';

const pressHandle = values => {
  user.update(values).then(() => {
    Alert.alert('操作成功', `更新个人资料`, [
      { text: '返回', onPress: Actions.pop },
    ])
  });
};

/* 
 如果需要将可观察对象作为props传入组件, 并且在组件中可被观察,
 那么需要在Scene中的component属性直接传递,
 如果使用Scene的额外属性的话可能会造成不可观察.
*/

module.exports = (
  <Scene
    key="editUserInfo"
    component={MyForm}
    title="更新个人信息"
    path="/personal/edit"
    user={user}
    hideTabBar
    onSubmit={pressHandle}
    {...navBarStyle}
  />
);
